package com.cea.papyrus.diagram.component;

import org.eclipse.gef.commands.CommandStack;
import org.eclipse.gef.palette.PaletteRoot;
import org.eclipse.gef.ui.actions.ActionRegistry;

import com.cea.papyrus.core.editor.DiagramPalette;
import com.cea.papyrus.core.editor.ModelManager;
import com.cea.papyrus.core.editor.abstracteditor.AbstractGraphicalPageWithFlyoutPalette;
import com.cea.papyrus.diagraminterchange2.di2.Diagram;

public class ComponentDiagramEditor extends AbstractGraphicalPageWithFlyoutPalette {
	private static DiagramPalette PALETTE_MODEL;

	/**
	 * @param diagram the diagram
	 * @param modelMngr the model mngr
	 */
	
	public ComponentDiagramEditor(Diagram diagram, ModelManager modelMngr) {
		super(diagram, modelMngr);
		// TODO Auto-generated constructor stub
	}
	
	/**
	 * Creates a new ComponentDiagramEditor, with a specified editing domain.
	 * @param diagram the diagram displayed by this editor
	 * @param modelMngr the instance of the model manager for the edited model
	 * * @param commandStack the command stack shared among all editors of a multiDiagramEditor 
	 */
	public ComponentDiagramEditor( Diagram diagram, ModelManager modelMngr, CommandStack commandStack, ActionRegistry actionRegistry){//, ModelResourceManager resourceManager){
		super( diagram, modelMngr, commandStack, actionRegistry);
	}
	/**
	 * In order to obtain the pallette Root.
	 * 
	 * @return the palette root
	 */
	@Override
	protected PaletteRoot getPaletteRoot() {
		if (PALETTE_MODEL == null) {
			PALETTE_MODEL = ComponentDiagramPaletteFactory.createPalette();
		}
		return PALETTE_MODEL;
	}
	
	/**
	 * Configure graphical viewer.
	 */
	@Override
	protected void configureGraphicalViewer() {
		super.configureGraphicalViewer();

		viewer = getGraphicalViewer();

		// create and register the EditPartFactory
		viewer.setEditPartFactory(new ComponentDiagramGraphicalEditPartsFactory(modelMngr));

		// configure the context menu provider
		cmProvider =
			new ComponentDiagramContextMenuProvider(viewer, getActionRegistry(),modelMngr);
		super.configureContextMenuProvider();
	}
}
